class Tools {
  constructor() { }
  random(n) {
    let len = n || 8
    let $chars = 'ABCDEFGHJKMNPQRSTWXYZ'
    let maxPos = $chars.length
    let id = ''
    for (let i = 0; i < len; i++) {
      id += $chars.charAt(Math.floor(Math.random() * maxPos))
    }
    return id
  }
  getuuid() {
    return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
      var r = (Math.random() * 16) | 0,
        v = c == "x" ? r : (r & 0x3) | 0x8;
      return v.toString(16);
    });
  }
  transformURL(str) {
    // 创建目标对象
    var $_REQUEST = new Object,
      // 截取数据字符串
      data =decodeURI(str.slice(str.indexOf("?"), str.length))  ,
      // 将数据字符串表现为数组
      aParams = data.substr(1).split("&");
    //console.log(data);
    //console.log(aParams);
    for (let i = 0; i < aParams.length; i++) {
      // 数据属性与数值分离
      var aParam = aParams[i].split("=");
      // 使用属性括号进行属性赋值
      $_REQUEST[aParam[0]] = aParam[1]
    }
    console.log('$_REQUEST', $_REQUEST)
    return $_REQUEST
  }

}

export const tools = new Tools()